package a13_observer;

import java.util.ArrayList;
import java.util.List;

public abstract class Subject {

	private List<IObserver> listeners = new ArrayList<>();

	public void addListener(IObserver listener) {
		listeners.add(listener);
	}

	public void removeListener(IObserver listener) {
		listeners.remove(listener);
	}

	public void clearListener() {
		listeners.clear();
	}

	void notifyListener() {
		for (IObserver o : listeners) {
			o.action();
		}
	}

	/**
	 * @return the listeners
	 */
	public List<IObserver> getListeners() {
		return listeners;
	}

	public abstract void startWork();

}
